use crate::http::IntoBytes;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HttpBody {
    pub(crate)  data: Vec<u8>
}

impl HttpBody {
    pub fn from_bytes<B: Into<Vec<u8>>>(bytes: B) -> Self {
        Self { data: bytes.into() }
    }

    pub fn content_length(&self) -> u64 {
        self.data.len() as u64
    }
}

impl IntoBytes for HttpBody {
    fn to_bytes(&self) -> Vec<u8> {
        self.data.clone()
    }
}
